/**
 * Filename: YNSingleton.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/3/1 11:06
 */
package com.github.postsanf.yinian.constants;

import android.app.Activity;
import android.graphics.Bitmap;

import com.github.postsanf.yinian.bean.YNAddress;
import com.github.postsanf.yinian.bean.YNAlbum;
import com.github.postsanf.yinian.bean.YNCouPon;
import com.github.postsanf.yinian.bean.YNNativeImage;
import com.github.postsanf.yinian.bean.YNShop;
import com.github.postsanf.yinian.bean.YNStatus;
import com.github.postsanf.yinian.utils.DisplayUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 单例
 */
public class YNSingleton {
    //单例模式实例
    private static YNSingleton instance = null;
    private List<YNAlbum> mAlbumList;
    private List<YNAlbum> mOfficialAlbumList;
    private List<YNAddress> mAddressList;
    private List<YNAlbum> mNewStudentAlbumList;
    private List<YNStatus> mStatusList;
    private YNStatus mCurStatus;
    private int screenWidth;
    private YNAlbum mCurAlbum;
    private List<YNNativeImage> mNativePhoto;
    private Bitmap shareBitmap;

    //synchronized 用于线程安全
    public synchronized static YNSingleton getInstance() {
        if (instance == null) {
            instance = new YNSingleton();
        }
        return instance;
    }

    public YNSingleton() {
        mAlbumList = new ArrayList<>();
        mOfficialAlbumList = new ArrayList<>();
        mAddressList=new ArrayList<>();
        mNewStudentAlbumList = new ArrayList<>();
        mStatusList = new ArrayList<>();
        mCurStatus = new YNStatus();
        mCurAlbum = new YNAlbum();
        mNativePhoto = new ArrayList<>();
        screenWidth = 0;

    }

    public void updateIsOfficialAlbum(YNAlbum item, int isInAlbum) {
        for (int i = 0; i < mOfficialAlbumList.size(); i++) {
            if (mOfficialAlbumList.get(i).equals(item)) {
                mOfficialAlbumList.get(i).setIsInAlbum(isInAlbum);
            }
        }
    }

    public List<YNNativeImage> getNativePhoto() {
        return mNativePhoto;
    }

    public void setNativePhoto(List<YNNativeImage> nativePhoto) {
        mNativePhoto = nativePhoto;
    }

    public List<YNAlbum> getOfficialAlbumList() {
        return mOfficialAlbumList;
    }

    public List<YNAlbum> getmNewStudentAlbumList() {
        return mNewStudentAlbumList;
    }

    public void setmNewStudentAlbumList(List<YNAlbum> mNewStudentAlbumList) {
        this.mNewStudentAlbumList = mNewStudentAlbumList;
    }
    public List<YNAddress> getmAddressList() {
        return mAddressList;
    }

    public void setmAddressList(List<YNAddress> mAddressList) {
        this.mAddressList = mAddressList;
    }

    public void setOfficialAlbumList(List<YNAlbum> officialAlbumList) {
        mOfficialAlbumList = officialAlbumList;
    }

    public List<YNAlbum> getAlbumList() {
        return mAlbumList;
    }

    public void setAlbumList(List<YNAlbum> albumList) {
        mAlbumList = albumList;
    }

    public void clearAlbumList() {
        mAlbumList.clear();
    }

    public List<YNStatus> getStatusList() {
        return mStatusList;
    }

    public void setStatusList(List<YNStatus> statusList) {
        mStatusList = statusList;
    }

    public void clearStatusList() {
        mStatusList.clear();
    }

    public int getScreenWidth() {
        return screenWidth;
    }

    public void setScreenWidth(Activity activity) {
        this.screenWidth = DisplayUtils.getScreenWidthPixels(activity);
    }

    public YNStatus getCurStatus() {
        return mCurStatus;
    }

    public void setCurStatus(YNStatus curStatus) {
        mCurStatus = curStatus;
    }

    public void clearCurStatus() {
        mCurStatus = new YNStatus();
    }

    public YNAlbum getCurAlbum() {
        return mCurAlbum;
    }

    public void setCurAlbum(YNAlbum curAlbum) {
        mCurAlbum = curAlbum;
    }

    public Bitmap getShareBitmap() {
        return shareBitmap;
    }

    public void setShareBitmap(Bitmap shareBitmap) {
        this.shareBitmap = shareBitmap;
    }
}
